package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql
	Redis
	QiNiuYun
	Jwt
}
type Mysql struct {
	Host     string
	Port     string
	User     string
	Password string
	Database string
}
type Redis struct {
	Host     string
	Port     string
	Password string
	Database int
}
type QiNiuYun struct {
	AccessKey string
	SecretKey string
	Bucket    string
	Url       string
}

type Jwt struct {
	APP_KEY string
}

var Config AppConfig

func Init() {

	viper.SetConfigFile("../appconfig/config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	err = viper.Unmarshal(&Config)
	if err != nil {
		panic(err)
	}
	fmt.Println("配置文件获取成功", Config)

}
